<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 流年 <liu21st@gmail.com>
// +----------------------------------------------------------------------

// 应用公共文件
//if (!=)

if (!function_exists("sendcode")){
    function sendcode($to, $datas){
        include_once (__DIR__."/../vendor/php-sms-sdk-master/SDK/SmsSDK.php");
        //主帐号
        $accountSid = '8a216da877bef0fe0177dd395b330b51';
        //主帐号Token
        $accountToken = '5621f5ab923846538816d515945e6b4a';
        //应用Id
        $appId = '8a216da877bef0fe0177dd395c490b57';
        //请求地址，格式如下，不需要写https://
        $serverIP = 'app.cloopen.com';
        //请求端口
        $serverPort = '8883';
        //REST版本号
        $softVersion = '2013-12-26';
        // 初始化REST SDK
        $rest = new REST($serverIP, $serverPort, $softVersion);
        $rest->setAccount($accountSid, $accountToken);
        $rest->setAppId($appId);
        // 发送模板短信
        $result = $rest->sendTemplateSMS($to, $datas, "1");
        if ($result->statusCode != 0) {
           return false;
        } else {
           return true;
        }
    }
}

